访问电脑版页面

导航:老古开发网手机版单片机AVR单片机

AVR单片机的串口查询设计

导读:
关键字:
AVR单片机,

* Code adapted from Atmel AVR ApplICaTIon Note AVR306

* PolLEDmode driver forUART, this is the similar to the

* library default putchar() and getchar() in ICCAVR

*/

#include


 

#include

#include “uart.h”

/* iniTIalize UART */

void InitUART( unsigned char baudrate )

{

UBRR = baudrate; /* set the baud rate */

UCR = BIT(RXEN) | BIT(TXEN); /* enable UART receiver and transmitter */

}

/* Read and write funcTIons */

unsigned char ReceiveByte( void )

{

while ( !(USR & (1《; /* return the data */

return UDR;

}

void TransmitByte( unsigned char data )

{

while ( !(USR & (1《; /* wait for empty transmit buffer */

UDR = data; /* start transmitTIon */

}

#ifdef TEST

/* main - a simple test program*/

void main( void )

{

InitUART( 11 ); /* set the baudrate to 19,200 bps using a

3.6864MHzcrystal */

while ( 1 ) /* forever */

{

TransmitByte( ReceiveByte() ); /* echo the received character */

}

}

#endif

来源:未知   作者:工程师周亮  2018/11/22 15:37:00
栏目: [ AVR单片机]

相关阅读

请问AVR的I/O口能直接作数码管位选吗?

 AVR用的晶振能低到多少? 

AVR单片机的RTOS-AVRX应用

怎样处理AVR 微控制器的NC引脚?

如何解决AVR单片机熔丝位锁死的问题

基于AVR单片机的现场可编程系统级集成电路

为什么选用AVR单片机来学习单片机

at90s8535 ad的输入端口中有不作ad的io脚是否可以做普通的io使用?

我最近在用AT90S2313时,EEPROM内的数据在上电时被冲掉?

为什么AVR单片机需要写1作为清0中断标志位

AT90S1200特点及功能简述

基于AVR单片机的医用臭氧治疗仪的设计与实现

基于AVR单片机的计算机智能节能插座设计

avr高手请进---向导生成的uart结构......

请教在线下载 

AVR单片机的串口查询设计

AVR8515看门狗晶振为1MHZ,复位间隔应为16us--2048us,为何为16--2048ms?

avr8535没有硬件对中断的sreg保护吗?是不是要在中断压栈sreg??谢谢!!

学习AVR(七)通用寄存器堆

avr-gcc写的一段代码,用来驱动led